//
//  UserViewController.m
//  PCR
//
//  Created by shumei on 16/6/3.
//  Copyright © 2016年 YM. All rights reserved.
//

#import "UserViewController.h"
#import "UserTableViewCell.h"
#import "YMBaseTabBarViewController.h"
#import "UserInfoViewController.h"
#import "SetViewController.h"
#import "InviteDetailViewController.h"
#import "InviteRankingViewController.h"


@interface UserViewController ()<
UITableViewDelegate,
UITableViewDataSource
>
{
    UITableView * _table_view;
    NSArray * _userListName;
}
@end

@implementation UserViewController


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [[YMBaseTabBarViewController shareInstance] setTabbarShow];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self setTopTitleWithTitle:@"我"];
    [self setRightItemsWithTitles:@[@"设置"] OrImages:nil];
    //我的界面列表的名字
    _userListName = [[NSArray alloc]initWithObjects:@"邀请明细",@"邀请排名",@"我的消息",@"QQ号码",@"淘宝号码",@"提现号码", nil];
    [self creatTableView];
    
    
    //设置界面
    [self actionWithBlocksRightButtonHandler:^(UIButton *sendBtn) {
        SetViewController * sc = [[SetViewController alloc]init];
        [self.navigationController pushViewController:sc animated:YES];
    }];
    
    
    
    
}

#pragma mark ---------------------------------创建表
-(void)creatTableView
{
    _table_view            = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,MainSCreen.width , MainSCreen.height - nav_Height - tabBar_height) style:UITableViewStylePlain];
    _table_view.delegate   = self;
    _table_view.dataSource = self;
    _table_view.rowHeight  = 100;
    [_table_view setTableFooterView:[[UIView alloc] init]];
    [self.view addSubview:_table_view];
}
#pragma mark ---------------------------------UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 1;
    }
    return _userListName.count;
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
{
    return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        return .1f;
    }
    return TableView_Default_SectionHight;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    if (indexPath.section == 0)
    {
         return 200 ;
    }
    return TableView_Default_RowHight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * TopCell = @"TopCell";
    static NSString *  Cell = @"Cell";
    if (indexPath.section == 0)
    {
        UserTableViewCell *cell = [[[NSBundle mainBundle]loadNibNamed:@"UserTableViewCell"
                                                                owner:nil
                                                              options:nil]objectAtIndex:0];
        if (cell == nil)
        {
            cell = [[UserTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1
                                           reuseIdentifier:TopCell];
        }
        return cell;
    }
    else
    {
        UserTableViewCell *cell = [[[NSBundle mainBundle]loadNibNamed:@"UserTableViewCell"
                                                                owner:nil
                                                              options:nil]objectAtIndex:1];
        if (cell == nil)
        {
            cell = [[UserTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:Cell];
        }
        
        
        cell.accessoryType  = UITableViewCellAccessoryDisclosureIndicator;

        cell.cell_name.text = _userListName[indexPath.row];
        if (indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2)
        {
            cell.cell_detailLabel.hidden = YES;
        }
        return cell;

    }
    
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YMBaseViewController * vc = nil;
    
    //个人信息界面
    if (indexPath.section == 0)
    {
        vc = [[UserInfoViewController alloc]init];
        
    }
    else
    {
        switch (indexPath.row) {
            case 0:
            {
                //邀请明细界面
                vc = [[InviteDetailViewController alloc]init];
            }
                break;
            case 1:
            {
                //邀请排名界面
                vc = [[InviteRankingViewController alloc] init];
            }
                break;
            case 2:
            {
                
            }
                break;
            case 3:
            {
                
            }
                break;
            case 4:
            {
                
            }
                break;
            case 5:
            {
                
            }
                break;
                
            default:
                break;
        }

    }
    
    [self.navigationController pushViewController:vc animated:YES];
    

}
//实现下拉头像变大的效果
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
